package diShiWuZhou;

import java.io.*;
import java.nio.Buffer;

public class two {
    public static void main(String[] args) {
        String srcFilePath1="D:\\two\\两个文件\\yi.java";
        String srcFilePath2="D:\\two\\两个文件\\er.java";
        String destFilePath="D:\\two\\两个文件\\san.java";
        try(
                //创建一个字符缓冲输入流包装原始的字符输入流
                BufferedReader br1=new BufferedReader(new FileReader(srcFilePath1));
                BufferedReader br2=new BufferedReader(new FileReader(srcFilePath2));

                //创建一个字符缓冲输出流管道包装原始的字符输出流
                BufferedWriter bw=new BufferedWriter(new FileWriter(destFilePath,true));
                ){

            String line;
            while((line=br1.readLine())!=null ||(line=br2.readLine())!= null){
                bw.write(line);
                bw.newLine();
                bw.flush();
            }
            System.out.println("内容合并完成");
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
